import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.http.Method;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

public class test {
    @Test
    public void testHttp() {
        String res = HttpUtil.get("https://www.itheima.com");
        System.out.println(res);
    }
    @Test
    public void testGetByParam() {
        // 构建查询参数
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("pageNum", 1);
        paramMap.put("pageSize", 5);
        // 分页查询护理项目
        String result = HttpUtil.get("http://localhost:8080/nursing/project/list", paramMap);
        System.out.println(result);
    }

    @Test
    public void testCreateRequest() {
        // 构建查询参数
        Map<String,Object> paramMap = new HashMap<>();
        paramMap.put("pageNum", 1);
        paramMap.put("pageSize", 5);
        // 分页查询护理项目
        HttpResponse response = HttpUtil.createRequest(Method.GET, "http://localhost:8080/nursing/project/list")
                .header("Authorization", "Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6Ijg5Y2Q1NDFjLTE5MjMtNDExZS04ZTQ5LTcyNjE3NTUwOGY2YSJ9.x6SiDgfR5scffl_AU5eoZ_qnt1CN3Ks5DMbyx9ZoS98u-LfpZs_394KXnTKa4JaTe6lvDC1fWJfTa9oCNKfu_w")
                .form(paramMap)
                .execute();
        if(response.isOk()){
            System.out.println(response.body());
        }
    }
}
